{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "increasing-boutique",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/replace-words\n",
    "\n",
    "\n",
    "Runtime: 220 ms, faster than 28.62% of Python3 online submissions for Replace Words.\n",
    "Memory Usage: 18.8 MB, less than 73.36% of Python3 online submissions for Replace Words.\n",
    "\n",
    "\n",
    "\n",
    "```python\n",
    "class Solution:\n",
    "    def replaceWords(self, dictionary: List[str], sentence: str) -> str:\n",
    "        #6:43\n",
    "        dictionary.sort()\n",
    "        results = []\n",
    "        for word in sentence.split(\" \"):\n",
    "            for root in dictionary:\n",
    "                if root == word[:len(root)]:\n",
    "                    results.append(root)\n",
    "                    break\n",
    "            else:\n",
    "                results.append(word)\n",
    "        return \" \".join(results)\n",
    "        #6:47\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "rotary-mother",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
